package cn.ubeta.b2c.user.favorite;

import android.text.TextUtils;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import cn.ubeta.b2c.R;
import cn.ubeta.b2c.api.ApiUser;
import cn.ubeta.b2c.bean.FavoriteProductInfo;
import cn.ubeta.b2c.common.ListFragment;
import cn.ubeta.b2c.common.ListFragmentConfig;
import cn.ubeta.b2c.widget.recyclerview.BaseViewHolder;

/**
 * Created by denny on 16/9/6.
 */

public class FavoriteFragment extends ListFragment<FavoriteProductInfo> {

    public static FavoriteFragment newInstance() {
        FavoriteFragment fragment = new FavoriteFragment();
        return fragment;
    }

    @Override
    protected ListFragmentConfig getConfig() {
        return new ListFragmentConfig(R.layout.item_favorite, 2);
    }

    @Override
    protected void bindItemView(BaseViewHolder helper, FavoriteProductInfo item) {
        // 商品图片
        SimpleDraweeView img = helper.getView(R.id.iv_product);
        // 商品标题
        String name = item.getName();
        if (!TextUtils.isEmpty(name)) {
            ((TextView) helper.getView(R.id.tv_name)).setText(name);
        }
    }

    @Override
    protected void loadData(int page) {
        ApiUser.getFavoriteProduct(page, getNetworkCallback());
    }

}
